﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WPF.DataBinding.DataContext
{
    /// <summary>
    /// Interaction logic for DataContextWindow.xaml
    /// </summary>
    public partial class DataContextWindow : Window
    {
        public Person source = new Person { Name = "Ahmet", Surname = "Demir", Age = 26 };
        public DataContextWindow()
        {
            InitializeComponent();
            this.grdDataContext.DataContext = source;
        }

        private void btnShow_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Person name: " + source.Name + ", person surname: " + source.Surname + ", person age: " + source.Age);
        }

        private void btnChange_Click(object sender, RoutedEventArgs e)
        {
            source.Age++;
            //source değişirken textbox güncellemesi için yazıldı. bu gerekli değil bunun yerine observablecollection
            //txtAge.GetBindingExpression(TextBox.TextProperty).UpdateTarget();
        }
    }
}
